function clearCart() {
    // 清空购物车逻辑
    fetch('/cart/clear', { method: 'POST' })
        .then(response => response.json())
        .then(result => {
            if (result.success) {
                alert('购物车已清空');
                location.reload();
            }
        });
}

// 示例填充数据
document.addEventListener('DOMContentLoaded', () => {
    const cartList = document.getElementById('cart-list');
    fetch('/cart/get-items')
        .then(response => response.json())
        .then(cartItems => {
            cartItems.forEach(item => {
                const li = document.createElement('li');
                li.textContent = `${item.name} - ￥${item.price} x ${item.quantity}`;
                cartList.appendChild(li);
            });
        });
});